%% FIGURE A-17
clear all
clc
% Add path 
% Determine where your m-file's folder is.
folder = fileparts(which("Figure_A_17.m")); 
% Add that folder plus all subfolders to the path.
addpath(genpath(folder)); 

% Saving path
file_dir = what('Figures'); 
spath=file_dir.path;

% Setting
hor=20;
jhor=0:hor;
Run_color_settings
% LOAD DATA
ResultsIP02=load("Results/DFMDGP_IPObsLag2.mat");
ResultsIP04=load("Results/DFMDGP_IPObsLag4.mat");
ResultsUnem02=load("Results/DFMDGP_UnemObsLag2.mat");
ResultsUnem04=load("Results/DFMDGP_UnemObsLag4.mat");


% Plot
clf
N_plot=2;
pln=1;
plotColumns=2;
figure(1)
for j=1:N_plot
            grid on
            pl=subplot(ceil(N_plot/plotColumns),plotColumns,pln);
            hold on
            
           if j==1
           % RMSE IP
            p0=plot(jhor,ResultsIP02.Results.RMSE_result(:,1), '--','LineWidth',4,'Color', line_colors(1,:)); 
            p1=plot(jhor,ResultsIP02.Results.RMSE_result(:,2), '-.','LineWidth',4,'Color', line_colors(2,:)); 
            p2=plot(jhor,ResultsIP02.Results.RMSE_result(:,3), '-','LineWidth',4,'Color', line_colors(3,:));
            p3=plot(jhor,ResultsIP02.Results.RMSE_result(:,4), '-o','LineWidth',2,'Color', line_colors(5,:)); 
            p4=plot(jhor,ResultsIP02.Results.RMSE_result(:,5), '-*','LineWidth',3,'Color', line_colors(6,:)); 
            hold off; axis tight
            xlim([0 hor]);
            set(gca,'XTick',0:4:hor,'XTickLabel',cellstr(num2str((0:4:hor)')),'Layer','top','FontSize',14)
            xlabel('Horizon')
          %  lh=legend([p0 p1 p2 p3 p4],{'VAR';'LP';'Pool EW';'Pool FC'; 'BLP'},'FontSize',16,'Location','northeast','Box','off');
            ylim([0 0.7])
            yticks(0:0.1:0.7)
            title('p=2','FontSize',16,'FontWeight','normal')
         
           elseif j==2
            % RMSE IP
            p0=plot(jhor,ResultsIP04.Results.RMSE_result(:,1), '--','LineWidth',4,'Color', line_colors(1,:)); 
            p1=plot(jhor,ResultsIP04.Results.RMSE_result(:,2), '-.','LineWidth',4,'Color', line_colors(2,:)); 
            p2=plot(jhor,ResultsIP04.Results.RMSE_result(:,3), '-','LineWidth',4,'Color', line_colors(3,:));
            p3=plot(jhor,ResultsIP04.Results.RMSE_result(:,4), '-o','LineWidth',2,'Color', line_colors(5,:)); 
            p4=plot(jhor,ResultsIP04.Results.RMSE_result(:,5), '-*','LineWidth',3,'Color', line_colors(6,:)); 
            hold off; axis tight
            xlim([0 hor]);
            set(gca,'XTick',0:4:hor,'XTickLabel',cellstr(num2str((0:4:hor)')),'Layer','top','FontSize',14)
            xlabel('Horizon')
            lh=legend([p0 p1 p2 p3 p4],{'VAR';'LP';'Pool EW';'Pool FC'; 'BLP'},'FontSize',16,'Location','southwest','Box','off');
            ylim([0 0.7])
            yticks(0:0.1:0.7)
            title('p=4','FontSize',16,'FontWeight','normal')
     
           end

            grid on
            ax = gca;             % Get current axes
            ax.GridLineStyle = ':';    % (Optional) Set grid line style
            ax.LineWidth = 2;         % This affects grid line thickness and axes box
            ax.GridColor = [0 0 0];
            x0=10;
            y0=10;
            width=900;
            height=400;      
            pln=pln+1;          
            set(gcf,'position',[x0,y0,width,height])
            hold off
end
saveas(figure(1),fullfile(spath,['DFM_ObsLagIPRMSE.eps']),'epsc');

% Plot
clf
N_plot=2;
pln=1;
plotColumns=2;
figure(2)
for j=1:N_plot
            grid on
            pl=subplot(ceil(N_plot/plotColumns),plotColumns,pln);
            hold on
            
           if j==1          
           % RMSE Unem
            p0=plot(jhor,ResultsUnem02.Results.RMSE_result(:,1), '--','LineWidth',4,'Color', line_colors(1,:)); 
            p1=plot(jhor,ResultsUnem02.Results.RMSE_result(:,2), '-.','LineWidth',4,'Color', line_colors(2,:)); 
            p2=plot(jhor,ResultsUnem02.Results.RMSE_result(:,3), '-','LineWidth',4,'Color', line_colors(3,:));
            p3=plot(jhor,ResultsUnem02.Results.RMSE_result(:,4), '-o','LineWidth',2,'Color', line_colors(5,:)); 
            p4=plot(jhor,ResultsUnem02.Results.RMSE_result(:,5), '-*','LineWidth',3,'Color', line_colors(6,:)); 
            hold off; axis tight
            xlim([0 hor]);
            set(gca,'XTick',0:4:hor,'XTickLabel',cellstr(num2str((0:4:hor)')),'Layer','top','FontSize',14)
            xlabel('Horizon')
           % lh=legend([p0 p1 p2 p3 p4],{'VAR';'LP';'Pool EW';'Pool FC'; 'BLP'},'FontSize',16,'Location','northeast','Box','off');
            ylim([0 1])
            yticks(0:0.2:1)
            title('p=2','FontSize',16,'FontWeight','normal')
         
            elseif j==2
            % RMSE Unem
            p0=plot(jhor,ResultsUnem04.Results.RMSE_result(:,1), '--','LineWidth',4,'Color', line_colors(1,:)); 
            p1=plot(jhor,ResultsUnem04.Results.RMSE_result(:,2), '-.','LineWidth',4,'Color', line_colors(2,:)); 
            p2=plot(jhor,ResultsUnem04.Results.RMSE_result(:,3), '-','LineWidth',4,'Color', line_colors(3,:));
            p3=plot(jhor,ResultsUnem04.Results.RMSE_result(:,4), '-o','LineWidth',2,'Color', line_colors(5,:)); 
            p4=plot(jhor,ResultsUnem04.Results.RMSE_result(:,5), '-*','LineWidth',3,'Color', line_colors(6,:)); 
            hold off; axis tight
            xlim([0 hor]);
            set(gca,'XTick',0:4:hor,'XTickLabel',cellstr(num2str((0:4:hor)')),'Layer','top','FontSize',14)
            xlabel('Horizon')
            lh=legend([p0 p1 p2 p3 p4],{'VAR';'LP';'Pool EW';'Pool FC'; 'BLP'},'FontSize',16,'Location','southwest','Box','off');
            ylim([0 0.8])
            yticks(0:0.2:0.8)
            title('p=4','FontSize',16,'FontWeight','normal')
     
           end

            grid on
            ax = gca;             % Get current axes
            ax.GridLineStyle = ':';    % (Optional) Set grid line style
            ax.LineWidth = 2;         % This affects grid line thickness and axes box
            ax.GridColor = [0 0 0];
            x0=10;
            y0=10;
            width=900;
            height=400;      
            pln=pln+1;          
            set(gcf,'position',[x0,y0,width,height])
            hold off
end
saveas(figure(2),fullfile(spath,['DFM_ObsLagUnemRMSE.eps']),'epsc');
